<?php


/**
 * Notes:
 * PROJECT_NAME : ERP v1.8 重构erp
 * User: 夏鱼儿<397072174@qq.com>
 * Date: 2024/3/26
 * Time: 15:13
 */

namespace app\service\base;

class Validate extends \think\Validate
{
    protected $rule = [
        'name'   => 'require|max:100',
        'pid'    => 'require|number',
        'page'   => 'require|number',
        "limit"  => "require|number",
        'id'     => 'require',
        'status' => 'require|in:1,2',
    ];

    protected $message = [
        'name.require'   => '请输入名称',
        'name.max'       => '名称最多不能超过100个字符',
        'pid.require'    => '请选择上级分类',
        'pid.number'     => 'pid类型不正确',
        'page.require'   => '请输入页码',
        'page.number'    => 'page类型不正确',
        'limit.require'  => '请输入每页显示条数',
        'limit.number'   => 'limit类型不正确',
        'id.require'     => '请选择要操作的数据',
        'status.require' => '状态不能为空',
        'status.in'      => '状态值不正确',
    ];

    protected $scene = [
        'list'       => ['page', 'limit'],
        "edit"       => ['id'],
        "editStatus" => ['id'],
        "del"        => ['id'],
        "detail"     => ['id'],
    ];

    public function __construct(array $rule = [], array $message = [], array $scene = [])
    {
        $this->rule    = array_merge($this->rule, $rule);
        $this->message = array_merge($this->message, $message);
        $this->scene   = array_merge($this->scene, $scene);
        parent::__construct();
    }
}